package com.dope_lh.myproject.demo1;

import com.dope_lh.myproject.request.ApiService;
import com.dope_lh.myproject.request.WeatherBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by dope_lh on 17-12-7.
 * M层
 */

public class RequestMode1 {

    private static final String BASE_URL = "http://www.weather.com.cn/";

    //http://www.weather.com.cn/data/cityinfo/101010100.html
    public void request(String detailId, Callback<WeatherBean> callback){
        //请求接口
        Retrofit retrofit  = new Retrofit.Builder()
                //代表root地址
                .baseUrl(BASE_URL)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        ApiService apiService = retrofit.create(ApiService.class);

        //请求
        Call<WeatherBean> weatherBeanCall = apiService.requestWeather(detailId);

        weatherBeanCall.enqueue(callback);
    }

}
